from tkinter import *
class TkinterClass:
    def __init__(self):
        self.__window = Tk()

    def setLabel(self,msg="你好，世界"):
        lable = Label(self.__window,text=msg)
        lable.pack()

    def setButton(self,text="点击",fg="red",command="",bg=""):
        """
        :param msg:  文案
        :param fg:  前景色
        :param command: 执行命令
        :param bg 背景色
        :return:
        """
        button = Button(self.__window,text=text,fg=fg,command=command)
        button.pack()
        return button

    def showTk(self):
        self.__window.mainloop()

def processOk():
    print("ok")
def processCancel():
    button2['bg'] = 'yellow'
    button2['text'] = '你真的要取消我'
    print("cancel")

tkObj = TkinterClass()
tkObj.setLabel("你好，python世界")
button1 = tkObj.setButton(text="点击点击我",fg="blue",command=processOk)
button2 = tkObj.setButton(text="取消",fg="red",command=processCancel)
tkObj.showTk()

